package tk.djcrazy.instantmessage.domain;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;

@Entity
@Table
public class UserEntity extends BaseBean{
	
	@Column(unique=true,nullable=false)
	private String userName;
	private String avatarPath="./image/default-avatar.jpg";
	@Column(nullable=false)
	private String password;
	@Column(unique=true,nullable=false)
	private String email;
	@OneToMany(mappedBy = "masterUser",fetch =FetchType.LAZY)
	@Fetch(FetchMode.SUBSELECT)  
 	private List<FriendShip> friends = new ArrayList<FriendShip>();
	@OneToMany(mappedBy = "ownUser" ,fetch =FetchType.LAZY)
	@Fetch(FetchMode.SUBSELECT)  
	private List<FriendGroup> groups = new ArrayList<FriendGroup>();
	private String statue;
	@Transient
	private LoginState loginState= LoginState.OFF_LINE;
	
 	public String getUserName() {
		return userName;
	}
	public void setUserName(String userName) {
		this.userName = userName;
	}
	public String getPassword() {
		return password;
	}
	public void setPassword(String password) {
		this.password = password;
	}
	public String getEmail() {
		return email;
	}
	public void setEmail(String email) {
		this.email = email;
	}
	public List<FriendShip> getFriends() {
		return friends;
	}
	public void setFriends(List<FriendShip> friends) {
		this.friends = friends;
	}
	public List<FriendGroup> getGroups() {
		return groups;
	}
	public void setGroups(List<FriendGroup> groups) {
		this.groups = groups;
	}
 	public String getAvatarPath() {
		return avatarPath;
	}
 	public void setAvatarPath(String avatarPath) {
		this.avatarPath = avatarPath;
	}
	@Override
	public String toString() {
		return "UserEntity [userName=" + userName + ", email=" + email + "]";
	}
	public LoginState getLoginState() {
		return loginState;
	}
	public void setLoginState(LoginState loginState) {
		this.loginState = loginState;
	}
	public String getStatue() {
		return statue;
	}
	public void setStatue(String statue) {
		this.statue = statue;
	}
}
